<template>
  <div class="list">
    <!-- 目录 -->
    <div class="nav">
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item :to="{ path: '/my' }">订单管理</el-breadcrumb-item>
        <el-breadcrumb-item>订单列表</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- 搜索框 -->
    <div class="ipt">
      <span>订单号：</span
      ><el-input
        @change="changeIpt"
        v-model="input"
        class="input"
        placeholder="订单号"
      ></el-input>
      <span>商品区域：</span
      ><el-select v-model="value" placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value"
        >
        </el-option>
      </el-select>
      <span>商品名称：</span
      ><el-input
        @change="changeIpt"
        v-model="input"
        class="input"
        placeholder="商品名称"
      ></el-input>
      <el-button type="primary" class="btn">查询</el-button>
      <el-button type="primary" class="btn">管理</el-button>
    </div>
    <!-- 表格 -->
    <div class="biaoge">
      <el-table :data="tableData" border style="width: 100%">
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column prop="id" label="ID" width="100">
        </el-table-column>
        <el-table-column prop="title" label="商品名称" width="180">
        </el-table-column>
        <el-table-column prop="num" label="购买数量" width="130">
        </el-table-column>
        <el-table-column prop="user.name" label="购买人" width="90">
        </el-table-column>
        <el-table-column prop="address" label="收货地址"> </el-table-column>
        <el-table-column prop="time" label="购买日期"> </el-table-column>

        <el-table-column label="操作" width="280">
          <template slot-scope="scope">
            <el-button size="mini" @click="handleEdit(scope.$index, scope.row)"
              >编辑</el-button
            >
            <el-button
              size="mini"
              type="danger"
              @click="handleDelete(scope.$index, scope.row)"
              >删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 分页器 -->
    <page :total="total" :pageSize="pageSize" @changePage="changePage"></page>
  </div>
</template>

<script>
import Page from "../../../components/Pagniton.vue";
export default {
  components: {
    Page,
  },
  data() {
    return {
      total: 10,
      pageSize: 1,
      currentPage: 1,
        type: 1,
      input: "",
      value: "",
      tableData: [],
      options: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
        {
          value: "选项3",
          label: "蚵仔煎",
        },
        {
          value: "选项4",
          label: "龙须面",
        },
        {
          value: "选项5",
          label: "北京烤鸭",
        },
      ],
    };
  },
  methods: {
    changeIpt() {},
    handleEdit() {},
    handleDelete() {},
    changePage(num) {
      this.currentPage = num;
      if (this.type == 1) {
        this.http(num);
      } else {
        this.tableData = this.list.slice((num - 1) * 3, num * 3);
      }
    },
    http(page){
        this.$api.orderList({page}).then((res) => {
      console.log(res.data.data.totalPage);
      if(res.data.status===200 ){
          this.tableData=res.data.data.list;
          this.total = res.data.data.totalPage;
      }
    
    });
    }
  },
  mounted() {
    this.http(1)
  },
};
</script>

<style lang="less" scoped>
.list {
  background: #eee;
  min-height: 789px;
  .nav {
    padding-left: 5px;
    padding-top: 5px;
    background-color: #eee;
  }
  .ipt {
    background-color: #fff;
    margin: 0 15px;
    margin-top: 10px;
    border-radius: 4px;
    span {
      margin-left: 15px;
    }
    display: flex;
    height: 70px;
    line-height: 70px;
    .input {
      width: 200px;
    }
    .btn {
      height: 40px;
      margin-top: 17px;
      margin-left: 15px;
    }
  }
  .biaoge {
    margin: 0 15px;
    margin-top: 30px;
  }
}
</style>